package com.example.template.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.http.ResponseEntity;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.template.entity.TJbLogs;
import com.example.template.service.TJbLogsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import io.swagger.annotations.*;

@RestController
@RequestMapping("/logs")
@Api(tags= "接口调用日志(TJbLogs)")
public class TJbLogsController {
    
    @Resource
    private TJbLogsService tJbLogsService;
	
	@PostMapping("/insert")
	@ApiOperation(value = "新增接口调用日志")
    public ResponseEntity insert(@RequestBody TJbLogs tJbLogs) {
        return ResponseEntity.ok(tJbLogsService.save(tJbLogs));
    }

    @PostMapping("/update")
	@ApiOperation(value = "更新接口调用日志")
    public ResponseEntity update(@RequestBody TJbLogs tJbLogs) {
        return ResponseEntity.ok(tJbLogsService.updateById(tJbLogs));
    }

    @PostMapping("/delete")
	@ApiOperation(value = "删除接口调用日志")
    public ResponseEntity delete(@RequestBody TJbLogs tJbLogs) {
        return ResponseEntity.ok(tJbLogsService.remove(new QueryWrapper<>(tJbLogs)));
    }
	
	@GetMapping("/selectOne")
	@ApiOperation(value = "获取接口调用日志详情")
    public ResponseEntity selectOne(TJbLogs tJbLogs) {
        return ResponseEntity.ok(tJbLogsService.getOne(new QueryWrapper<>(tJbLogs)));
    }

    @GetMapping("/selectPageList")
	@ApiOperation(value = "分页查询接口调用日志数据")
    public ResponseEntity selectPageList(Page<TJbLogs> page, TJbLogs tJbLogs) {
        return ResponseEntity.ok(tJbLogsService.page(page, new LambdaQueryWrapper<>(tJbLogs).orderByDesc(TJbLogs::getId)));
    }
}
